<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2019/8/22
  Time: 15:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="page" />
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" href="${ctx}/css/templatemo_style.css"/> <!-- 页面整体布局样式定义 -->
    <link rel="stylesheet" href="${ctx}/css/ddsmoothmenu.css" /> <!-- 菜单样式定义 -->
    <script src="${ctx}/js/jquery-1.4.3.min.js"></script>
    <script type="text/javascript">
        var ctx="${pageContext.request.contextPath}";
        function showUserName()
        {
            var name ="${user.username}";
            if(name != "")
            {
                $("#login").html(name);
                $("#exitP").show();
                $("#login").attr("href",ctx+"/user?flag=info&userId=${user.userId}");
            }
            else
            {
                $("#login").html("登陆");
                $("#exitP").hide();
                $("#login").attr("href",ctx+"/user?flag=login");
            }
        }
        function shuaxin()
        {
            location.reload();
        }
        $(document).ready(function(){
            showUserName();

            $("#symy").css("color","red");

            $(".sl").change(function(){
                var zhi=$(this).attr("id");
                var sl=$(this).val();
                 $.ajax({
                      url: ctx +"/shuliang",
                      type:"post",
                      data:{"quantity":sl,"ycshoppingid":zhi},
                      dataType:"json",
                      success:function (data) {
                          if(data.code==200)
                          {
                              var result = data.result;
                              console.log(result);
                              if(result)
                              {
                                  $("#gxzt").val("更新成功,请刷新价格");
                                  $("#gxzt").css("color","green");
                              }
                              else
                              {
                                  $("#gxzt").val("更新失败，该商品库存不足");
                                  $("#gxzt").css("color","red");

                              }
                          }
                      }
                 });
            });
        });

    </script>
</head>

<body>
<div id="templatemo_body_wrapper">
    <div id="templatemo_wrapper">


        <!-- header -->
        <div id="templatemo_header">
            <div id="site_title"><h1><a href="#">穿美在线鞋城</a></h1></div>
            <div id="header_right">
                <p>
                    <a href="#" id="login">登录</a>&nbsp;
                    <span id="exitP" style="display: none"><a href="${ctx}/user?flag=logout" id="exit">注销</a></span>
                </p>
            </div>
            <div class="cleaner"></div>
        </div>
        <!-- END of templatemo_header -->


        <!-- menu -->
        <div id="templatemo_menubar">
            <div id="top_nav" class="ddsmoothmenu">
                <ul>
                    <li><a href="${ctx}/home?flag=home" class="selected">首页</a></li>
                    <li><a href="${ctx}/product?flag=product">产品</a></li>
                    <li><a href="${ctx}/shopcar?tz=gocar" class="selected">我的购物车</a></li>
                    <li><a href="${ctx}/order?flag=fol">我的订单</a></li>
                </ul>
                <br style="clear: left" />
            </div> <!-- end of ddsmoothmenu -->
        </div><!-- END of templatemo_menubar -->


        <!-- main -->
        <div id="templatemo_main">
            <!-- 侧边栏 -->
            <div id="sidebar" class="float_l">
                <!-- sidebar 1 -->
                <div class="sidebar_box"><span class="bottom"></span>
                    <h3>品牌</h3>
                    <div class="content">
                        <ul class="sidebar_list">
                            <c:forEach items="${list}" var="x">
                                <li><a href="${ctx}/home?flag=pp&pinpai=${x.name}">${x.name}</a></li>
                            </c:forEach>
                        </ul>
                    </div>
                </div>
                <!-- sidebar 2 -->
                <div class="sidebar_box"><span class="bottom"></span>
                    <h3>热卖单品 </h3>
                    <div class="content">
                        <c:forEach items="${list2}" var="x">
                            <div class="bs_box">
                                <a href="${ctx}/home?flag=xq&productId=${x.productId}"><img src='${ctx}${x.imgpath}' alt="image" style="width:62px;height:72px"/></a>
                                <p>${x.feature}</p>
                                <p class="price">${x.price}</p>
                                <div class="cleaner"></div>
                            </div>
                        </c:forEach>
                    </div>
                </div>
            </div><!-- END of sidebar -->

            <!-- 内容展示区 -->
            <div id="content" class="float_r">
                <c:if test="${listlength == '0'}">
                <h3 id="symy">购物车里啥也没有，你咋不心思心思添加点东西呢！</h3>
                </c:if>
                <c:if test="${listlength != '0'}">
                <h3>购物车</h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${yichumessage}

                <table width="680px" cellspacing="0" cellpadding="5">
                    <tr bgcolor="#ddd">
                        <th width="220" align="left">图片 </th>
                        <th width="180" align="left">商品描述 </th>
                        <th width="100" align="center">数量 </th>
                        <th width="60" align="right">价格 </th>
                        <th width="60" align="right">小计 </th>
                        <th width="90"></th>
                    </tr>
                    <c:forEach items="${shopcartlist}" var="shopcarlist" >
                    <tr>

                        <td><img src="${ctx}${shopcarlist.imgpath}" alt="image 1" /></td>
                        <td>${shopcarlist.feature}</td>
                        <td align="center">
                            <input type="text" id="${shopcarlist.shoppingCartId}" class="sl"name="quantity" value="${shopcarlist.quantity}"  style="width:22px;height:12px;text-align:center;" />
                        </td>
                        <td align="right">${shopcarlist.price}</td>
                        <td align="right">${shopcarlist.smallmoney}</td>
                        <td align="center">
                            <a href="${ctx}/shopcar?tz=yichu&shoppingCartId=${shopcarlist.shoppingCartId}"><img src="${ctx}/images/remove_x.gif" alt="remove" /><br />移除</a>
                        </td>
                        <span name="cartId" style="color:blue;display: none">SPAA5A8A606</span>
                    </tr>
                    </c:forEach>
                    <tr>

                        <td colspan="6" align="center"  height="30px"><span id="update">如果你已修改了商品，请单击 <a href="${ctx}/shopcar?tz=gocar"><strong>更新</strong></a></span>&nbsp;&nbsp;</td>

                    </tr>
                    <tr>
                        <td colspan="3" align="right"  height="30px">显示更新的状态信息&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="gxzt" disabled="true" style="background:none;border:0"></td>

                        <td align="right" style="background:#ddd; font-weight:bold"> 合计 </td>

                        <td align="right" style="background:#ddd; font-weight:bold"> ￥${countmoney} </td>
                        <td style="background:#ddd; font-weight:bold"> </td>
                    </tr>
                </table>


                <div style="float:right; width: 215px; margin-top: 20px;">
                    <p><a href="${ctx}/shopcar?tz=jiesuan">结算</a></p>
                    <p><a href="${ctx}/product?flag=product">继续购物</a></p>
                </div>
                </c:if>
            </div>
            <div class="cleaner"></div>
        </div><!-- END of templatemo_main -->

        <!-- footer -->
        <div id="templatemo_footer">
            <p>
                <a href="${ctx}/home?flag=home" class="selected">首页</a> | <a href="${ctx}/product?flag=product">产品</a> | <a href="${ctx}/shopcar?tz=gocar">我的购物车</a> | <a href="${ctx}/order?flag=fol">我的订单</a>
            </p>
            版权所有 (c) 2018 <a href="javascript:void(0);">金桥软件</a>
        </div><!-- END of templatemo_footer -->


    </div><!-- END of templatemo_wrapper -->
</div><!-- END of templatemo_body_wrapper -->
</body>
</html>